package com.ten.jinxiancun.controller;

import com.ten.jinxiancun.entity.Menu;
import com.ten.jinxiancun.server.impl.menuServerImpl;
import com.ten.jinxiancun.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*
* 动态模块控制器
* */
@RestController
@RequestMapping("/dynamicMeun")
public class dynamicMenuController {

    /*@Autowired
    menuServer ms;*/
    @Autowired
    menuServerImpl msl;
    @RequestMapping("/dynamicMeunRun")
    @ResponseBody
    public List<Menu> getAllModuse(Integer id) {
        return msl.MenuLogFind(id);

    }
    /*树形图模块*/
    @RequestMapping("/getMenuAll")
    public  Object getMenuAll(@RequestParam Map<String,Object> map){
        List<Map<String, Object>> menu= msl.getMenuFind(map);
        Map<String, Object> check = new HashMap<>();
        for (Map<String, Object> m : menu) {
            check.put("type", 0);
            check.put("checked", 0);
            m.put("checkArr", check);
        }
        Result res = new Result("0", "操作成功", msl.countFind(map), menu);
        System.out.println("==========>" + res);
        return res;
    }
    @RequestMapping("/getMODSsss")
    public Object getAllsss(@RequestParam Map<String, Object> map) {

        Result res = new Result("0", "操作成功", msl.countFind(map), msl.getMenuFind(map));

        System.out.println("==========>" + res);
        return res;
    }
    }
